<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<view class="content">
			<button @click="toMyFirstPage">跳转向我的第一个页面</button>
		</view>
		<view class="content">
			<button @click="addName">添加缓存</button>
			<button @click="removeName">删除缓存</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '你好我是uni-app'
			}
		},
		onLoad() {
			/* 延迟5秒钟处理 如果5秒之内,没有任何动作,就会跳转向myMessage */
			setTimeout(() => {
			  this.toMessage();
			}, 5000);
		},
		methods: {
			toMessage(){
				/* 向导航栏页面跳转不可以使用navigateTo 必须使用switchTab */
				uni.switchTab({
					url: "/pages/myMessage/myMessage"
				});
			},
			addName(){
				console.log("开始添加缓存");
				uni.setStorageSync("name","王翠花");
			},
			removeName(){
				console.log("移除缓存");
				uni.removeStorageSync("name");
			},
			toMyFirstPage(){
				console.log("触发了点击时间,即将跳转向目标页面")
				uni.navigateTo({
					url: "/pages/myFirstPage/myFirstPage"
				})
				/* uni.switchTab({
					url: "/pages/myFirstPage/myFirstPage"
				}) */
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
